home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / STREND.C < prev    next >
Text File  |  1993-01-04  |  768b  |  36 lines

  1.  
  2. /*  File   : strend.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 23 April 1984
  5.     Defines: strend()
  6.  
  7.     strend(s) returns a character pointer to the NUL which ends s.  That
  8.     is,  strend(s)-s  ==  strlen(s). This is useful for adding things at
  9.     the end of strings.  It is redundant, because  strchr(s,'\0')  could
  10.     be used instead, but this is clearer and faster.
  11.     Beware: the asm version works only if strlen(s) < 65535.
  12. */
  13.  
  14. #include "strings.h"
  15.  
  16. #if     VaxAsm
  17.  
  18. char *strend(s)
  19.     char *s;
  20.     {
  21.         asm("locc $0,$65535,*4(ap)");
  22.         asm("movl r1,r0");
  23.     }
  24.  
  25. #else  ~VaxAsm
  26.  
  27. char *strend(s)
  28.     register char *s;
  29.     {
  30.         while (*s++);
  31.         return s-1;
  32.     }
  33.  
  34. #endif  VaxAsm
  35.  
  36.